import com.lucnn.diamond.spring.bean.Color;
import com.lucnn.diamond.spring.config.ImportConfig;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class IocTestImport {

    ApplicationContext ctx = new AnnotationConfigApplicationContext(ImportConfig.class);

    private void printBeans(ApplicationContext ctx){
        String[] names = ctx.getBeanDefinitionNames();
        for(String name:names){
            System.out.println(name);
        }
    }

    @Test
    public void testImport(){
        printBeans(ctx);
        Color color = ctx.getBean(Color.class);
        System.out.println(color);

        Object bean = ctx.getBean("myFactoryBean");
        System.out.println(bean.getClass());
        Object bean2 = ctx.getBean("&myFactoryBean");
        System.out.println(bean2.getClass());
    }


}
